<?php
/*
 * Created on 18 d�c. 2005
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
include_once('IniFile.php');
include_once('Format.php');

$LanguageTerms;
$DefaultLanguage = 'en';
$CurrentLanguage;

function loadLanguage()
{	
	global $LanguageTerms, $CurrentLanguage;

	$CurrentLanguage = empty($_GET['lang']) ? getConfiguration('global', 'DefaultLanguage') : $_GET['lang'];
	
	$fileName = '../Languages/' . $CurrentLanguage . '.txt';
	
	if ( file_exists($fileName) )
		$LanguageTerms = loadIniFile($fileName);
}

function getTerm($section, $term)
{
	global $LanguageTerms;
	
	if ( definedValue($LanguageTerms, $section, $term) )

		$value = getValue($LanguageTerms, $section, $term);
		
	else
	
		$value = "???$section::$term???";

	return $value;
}

function termExists($section, $term)
{
	global $LanguageTerms;

	return definedValue($LanguageTerms, $section, $term);
}

function formatUrl($url, $lang='')
{
	global $CurrentLanguage;
	global $DefaultLanguage;
	
	if ( empty($lang) )
		$lang = $CurrentLanguage;
		
	if ( $lang==$DefaultLanguage )
		return $url;
		
	else
		return "/$lang$url";
}

function getCurrentLanguage()
{
	global $CurrentLanguage;
	
	return $CurrentLanguage;
}
 
?>
